/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Gestores;

import Datos.CantonDB;
import Datos.ClienteDB;
import Negocio.Canton;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Dvid
 */
public class GestorCanton {
    
     ArrayList cantones=new ArrayList();
    
    public ArrayList getCantones() {
        return cantones;
    }

    public void setCantones(ArrayList cant) {
        this.cantones = cant;
    }
    
        
    public void listar() {
        try {
            CantonDB cantonDB = new CantonDB();
            setCantones(cantonDB.listar());
        } catch (SQLException ex) {
            Logger.getLogger(GestorCanton.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    
     public int grabar(Canton canton) {
        try {
            CantonDB cantonDB = new CantonDB();
            cantonDB.grabar(canton);
            return 0;
        } catch (SQLException ex) {
            return 1;
        }}

    public Canton buscar(String id) {
       Canton aux=null;
        try {
            
            CantonDB cantonDB = new CantonDB();
            aux = cantonDB.buscar(id);
            aux.setId(aux.getId());
            aux.setDescripcion(aux.getDescripcion());
            aux.setProvincia(aux.getProvincia());
           
        return aux;
        } catch (SQLException ex) {
            Logger.getLogger(Canton.class.getName()).log(Level.SEVERE, null, ex);
            return aux;
        }
    }
}
